#pragma once
#include "../utils/factory.hh"
#include "../config/config.hh"
#include <stdexcept>

namespace ngintoy
{
    namespace platform
    {
        using config = config::config;

        struct platform : utils::factory<platform, config &>
        {
            virtual bool poll() = 0;    // returns false for quiting.
            virtual double now() = 0;   // returns current time (high resolution clock), in seconds

            // - POST CONDITION
            //   have at least 1 platform
            static void validate()
            {
                if (registry().size() == 0)
                    throw std::logic_error{"no platform available? YOU MUST BE KIDDING!"};
            }

        protected:
            platform() {}
        };
    }
}

